package com.bwie.parkdemo.mvvm.model;

import android.content.Context;

import com.bwie.lib_core.base.BaseEntity;
import com.bwie.lib_core.mvvm.base.BaseModel;
import com.bwie.lib_core.network.HttpRetrofitFactory;
import com.bwie.lib_core.network.HttpType;
import com.bwie.parkdemo.dao.LoginUserServe;
import com.bwie.parkdemo.mvvm.model.entity.LoginEntity;
import com.bwie.parkdemo.mvvm.model.entity.SysSignEntity;

import io.reactivex.Observable;
import okhttp3.RequestBody;

/**
 * 签到签退model
 * */
public class SysSignModel extends BaseModel{
    @Override
    public Observable<BaseEntity> request(RequestBody... bodyes) {
        Observable<SysSignEntity>source = HttpRetrofitFactory.getInstance()
                .factory(HttpType.TOKENINTERFACE).getRetrofit()
                .create(Api.class).requestStartSign(bodyes[0]);
        return changeOB(source);
    }

    //签退
    public Observable<BaseEntity> requestEndSign(RequestBody body){
        Observable<SysSignEntity>source = HttpRetrofitFactory.getInstance()
                .factory(HttpType.TOKENINTERFACE).getRetrofit()
                .create(Api.class).requestEndSign(body);
        return changeOB(source);
    }

    //获取userid
    public LoginEntity.Values requestUser(Context ctx) {
        return new LoginUserServe(ctx).selUser();
    }


    @Override
    public void cleared() {

    }
}
